import fs from 'fs'
export default function replaceLiveAppId(pagesPath: string, environmentObj: ImportMetaEnv) {
    const pageStr = fs.readFileSync(pagesPath, { encoding: 'utf-8' })
    const pagesObject = JSON.parse(pageStr)
    pagesObject.subPackages.map((item: any) => {
        if (item.plugins && item.plugins['live-player-plugin']) {
            item.plugins['live-player-plugin'] = {
                version: environmentObj.VITE_WX_LIVE_VERSION,
                provider: environmentObj.VITE_WX_LIVE_ID,
            }
        }
        return item
    })
    fs.writeFileSync(pagesPath, JSON.stringify(pagesObject), {
        flag: 'w',
    })
}
